import 'package:seedfour/generated/json/base/json_convert_content.dart';
import 'package:seedfour/app/models/income_alloc_content_entity.dart';

IncomeAllocContentEntity $IncomeAllocContentEntityFromJson(
    Map<String, dynamic> json) {
  final IncomeAllocContentEntity incomeAllocContentEntity = IncomeAllocContentEntity();
  final List<IncomeAllocContentPlans>? plans = (json['plans'] as List<dynamic>?)
      ?.map(
          (e) =>
      jsonConvert.convert<IncomeAllocContentPlans>(
          e) as IncomeAllocContentPlans)
      .toList();
  if (plans != null) {
    incomeAllocContentEntity.plans = plans;
  }
  final int? status = jsonConvert.convert<int>(json['status']);
  if (status != null) {
    incomeAllocContentEntity.status = status;
  }
  final int? createDate = jsonConvert.convert<int>(json['createDate']);
  if (createDate != null) {
    incomeAllocContentEntity.createDate = createDate;
  }
  final IncomeAllocContentOrder? order = jsonConvert.convert<
      IncomeAllocContentOrder>(json['order']);
  if (order != null) {
    incomeAllocContentEntity.order = order;
  }
  final IncomeAllocContentRemain? remain = jsonConvert.convert<
      IncomeAllocContentRemain>(json['remain']);
  if (remain != null) {
    incomeAllocContentEntity.remain = remain;
  }
  return incomeAllocContentEntity;
}

Map<String, dynamic> $IncomeAllocContentEntityToJson(
    IncomeAllocContentEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['plans'] = entity.plans.map((v) => v.toJson()).toList();
  data['status'] = entity.status;
  data['createDate'] = entity.createDate;
  data['order'] = entity.order.toJson();
  data['remain'] = entity.remain.toJson();
  return data;
}

extension IncomeAllocContentEntityExtension on IncomeAllocContentEntity {
  IncomeAllocContentEntity copyWith({
    List<IncomeAllocContentPlans>? plans,
    int? status,
    int? createDate,
    IncomeAllocContentOrder? order,
    IncomeAllocContentRemain? remain,
  }) {
    return IncomeAllocContentEntity()
      ..plans = plans ?? this.plans
      ..status = status ?? this.status
      ..createDate = createDate ?? this.createDate
      ..order = order ?? this.order
      ..remain = remain ?? this.remain;
  }
}

IncomeAllocContentPlans $IncomeAllocContentPlansFromJson(
    Map<String, dynamic> json) {
  final IncomeAllocContentPlans incomeAllocContentPlans = IncomeAllocContentPlans();
  final List<IncomeAllocContentPlansAlloc>? alloc = (json['alloc'] as List<
      dynamic>?)?.map(
          (e) =>
      jsonConvert.convert<IncomeAllocContentPlansAlloc>(
          e) as IncomeAllocContentPlansAlloc).toList();
  if (alloc != null) {
    incomeAllocContentPlans.alloc = alloc;
  }
  final int? totalAmount = jsonConvert.convert<int>(json['totalAmount']);
  if (totalAmount != null) {
    incomeAllocContentPlans.totalAmount = totalAmount;
  }
  final double? totalPercent = jsonConvert.convert<double>(
      json['totalPercent']);
  if (totalPercent != null) {
    incomeAllocContentPlans.totalPercent = totalPercent;
  }
  final int? planStatus = jsonConvert.convert<int>(json['planStatus']);
  if (planStatus != null) {
    incomeAllocContentPlans.planStatus = planStatus;
  }
  final String? approveUid = jsonConvert.convert<String>(json['approveUid']);
  if (approveUid != null) {
    incomeAllocContentPlans.approveUid = approveUid;
  }
  final String? approveDate = jsonConvert.convert<String>(json['approveDate']);
  if (approveDate != null) {
    incomeAllocContentPlans.approveDate = approveDate;
  }
  return incomeAllocContentPlans;
}

Map<String, dynamic> $IncomeAllocContentPlansToJson(
    IncomeAllocContentPlans entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['alloc'] = entity.alloc.map((v) => v.toJson()).toList();
  data['totalAmount'] = entity.totalAmount;
  data['totalPercent'] = entity.totalPercent;
  data['planStatus'] = entity.planStatus;
  data['approveUid'] = entity.approveUid;
  data['approveDate'] = entity.approveDate;
  return data;
}

extension IncomeAllocContentPlansExtension on IncomeAllocContentPlans {
  IncomeAllocContentPlans copyWith({
    List<IncomeAllocContentPlansAlloc>? alloc,
    int? totalAmount,
    double? totalPercent,
    int? planStatus,
    String? approveUid,
    String? approveDate,
  }) {
    return IncomeAllocContentPlans()
      ..alloc = alloc ?? this.alloc
      ..totalAmount = totalAmount ?? this.totalAmount
      ..totalPercent = totalPercent ?? this.totalPercent
      ..planStatus = planStatus ?? this.planStatus
      ..approveUid = approveUid ?? this.approveUid
      ..approveDate = approveDate ?? this.approveDate;
  }
}

IncomeAllocContentPlansAlloc $IncomeAllocContentPlansAllocFromJson(
    Map<String, dynamic> json) {
  final IncomeAllocContentPlansAlloc incomeAllocContentPlansAlloc = IncomeAllocContentPlansAlloc();
  final String? uid = jsonConvert.convert<String>(json['uid']);
  if (uid != null) {
    incomeAllocContentPlansAlloc.uid = uid;
  }
  final double? percent = jsonConvert.convert<double>(json['percent']);
  if (percent != null) {
    incomeAllocContentPlansAlloc.percent = percent;
  }
  final int? amount = jsonConvert.convert<int>(json['amount']);
  if (amount != null) {
    incomeAllocContentPlansAlloc.amount = amount;
  }
  final String? mobile = jsonConvert.convert<String>(json['mobile']);
  if (mobile != null) {
    incomeAllocContentPlansAlloc.mobile = mobile;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    incomeAllocContentPlansAlloc.name = name;
  }
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    incomeAllocContentPlansAlloc.id = id;
  }
  return incomeAllocContentPlansAlloc;
}

Map<String, dynamic> $IncomeAllocContentPlansAllocToJson(
    IncomeAllocContentPlansAlloc entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['uid'] = entity.uid;
  data['percent'] = entity.percent;
  data['amount'] = entity.amount;
  data['mobile'] = entity.mobile;
  data['name'] = entity.name;
  data['id'] = entity.id;
  return data;
}

extension IncomeAllocContentPlansAllocExtension on IncomeAllocContentPlansAlloc {
  IncomeAllocContentPlansAlloc copyWith({
    String? uid,
    double? percent,
    int? amount,
    String? mobile,
    String? name,
    String? id,
  }) {
    return IncomeAllocContentPlansAlloc()
      ..uid = uid ?? this.uid
      ..percent = percent ?? this.percent
      ..amount = amount ?? this.amount
      ..mobile = mobile ?? this.mobile
      ..name = name ?? this.name
      ..id = id ?? this.id;
  }
}

IncomeAllocContentOrder $IncomeAllocContentOrderFromJson(
    Map<String, dynamic> json) {
  final IncomeAllocContentOrder incomeAllocContentOrder = IncomeAllocContentOrder();
  final String? title = jsonConvert.convert<String>(json['title']);
  if (title != null) {
    incomeAllocContentOrder.title = title;
  }
  final int? orderAmount = jsonConvert.convert<int>(json['orderAmount']);
  if (orderAmount != null) {
    incomeAllocContentOrder.orderAmount = orderAmount;
  }
  final int? collectionDate = jsonConvert.convert<int>(json['collectionDate']);
  if (collectionDate != null) {
    incomeAllocContentOrder.collectionDate = collectionDate;
  }
  final String? agentUsername = jsonConvert.convert<String>(
      json['agentUsername']);
  if (agentUsername != null) {
    incomeAllocContentOrder.agentUsername = agentUsername;
  }
  return incomeAllocContentOrder;
}

Map<String, dynamic> $IncomeAllocContentOrderToJson(
    IncomeAllocContentOrder entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['title'] = entity.title;
  data['orderAmount'] = entity.orderAmount;
  data['collectionDate'] = entity.collectionDate;
  data['agentUsername'] = entity.agentUsername;
  return data;
}

extension IncomeAllocContentOrderExtension on IncomeAllocContentOrder {
  IncomeAllocContentOrder copyWith({
    String? title,
    int? orderAmount,
    int? collectionDate,
    String? agentUsername,
  }) {
    return IncomeAllocContentOrder()
      ..title = title ?? this.title
      ..orderAmount = orderAmount ?? this.orderAmount
      ..collectionDate = collectionDate ?? this.collectionDate
      ..agentUsername = agentUsername ?? this.agentUsername;
  }
}

IncomeAllocContentRemain $IncomeAllocContentRemainFromJson(
    Map<String, dynamic> json) {
  final IncomeAllocContentRemain incomeAllocContentRemain = IncomeAllocContentRemain();
  final double? percent = jsonConvert.convert<double>(json['percent']);
  if (percent != null) {
    incomeAllocContentRemain.percent = percent;
  }
  final int? amount = jsonConvert.convert<int>(json['amount']);
  if (amount != null) {
    incomeAllocContentRemain.amount = amount;
  }
  return incomeAllocContentRemain;
}

Map<String, dynamic> $IncomeAllocContentRemainToJson(
    IncomeAllocContentRemain entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['percent'] = entity.percent;
  data['amount'] = entity.amount;
  return data;
}

extension IncomeAllocContentRemainExtension on IncomeAllocContentRemain {
  IncomeAllocContentRemain copyWith({
    double? percent,
    int? amount,
  }) {
    return IncomeAllocContentRemain()
      ..percent = percent ?? this.percent
      ..amount = amount ?? this.amount;
  }
}